<template>
  <div>
    用户名:<input v-model="username" type="text" /><br />
    姓名:
    <input v-model="user.name" type="text" />
    年龄:
    <input v-model="user.age" type="text" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: "",
      user: {
        name: "",
        age: "",
      },
    };
  },
  methods: {},
  watch: {
    username(newVal, oldVal) {
      console.log(newVal, oldVal);
    },
    user: {
      handler() {
        console.log(this.user);
      },
      deep: true,
      immediate: true,
    },
  },
};
</script>

<style>
</style>